package com.pyb.module.live.adapter;

import android.os.Bundle;
import android.util.Log;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager;
import androidx.lifecycle.Lifecycle;
import androidx.recyclerview.widget.RecyclerView;
import androidx.viewpager2.adapter.FragmentStateAdapter;

import com.alibaba.android.arouter.launcher.ARouter;
import com.pyb.java.commonutil.ARouterExtraKeys;
import com.pyb.java.commonutil.constant.RouterFragmentPath;

import java.util.List;

public class VideoVerticalAdapter extends FragmentStateAdapter {
    private List<String> lists;

    public VideoVerticalAdapter(@NonNull FragmentActivity fragmentActivity, List<String> lists) {
        super(fragmentActivity);
        this.lists = lists;
    }

    @NonNull
    @Override
    public Fragment createFragment(int position) {
        Bundle bundle = new Bundle();
        bundle.putString(ARouterExtraKeys.KEY_URL, lists.get(position));
        Fragment fragment = (Fragment) ARouter.getInstance().
                build(RouterFragmentPath.Live.PAGER_HOME_VIDEO_ITEM_FM)
                .navigation();
        fragment.setArguments(bundle);
        return fragment;
    }

    @Override
    public int getItemCount() {
        return lists.size();
    }
}
